package DP;

import Sort.堆排序;
import org.junit.Test;

import java.util.Arrays;

/**
 * @BelongsProject: SeniorArchitect-LeetCode
 * @BelongsPackage: DP
 * @Author: zhuangxiaoyan
 * @CreateTime: 2023-10-22  14:51
 * @Description: TODO
 * @Version: 1.0
 */
public class 不同路径62 {
    // 采用的动态规划的思路 dp[i][j]=dp[i][j-1]+dp[i-1][j] dp[0][j]=1;dp[i][0]=1;
    public int uniquePaths(int m, int n) {
        if (m<=0){
            return 0;
        }
        int[][] dp=new int[m][n];
        for (int i=0;i<n;i++){
            dp[0][i]=1;
        }
        for (int j=0;j<m;j++){
            dp[j][0]=1;
        }
        for (int i=1;i<m;i++){
            for (int j=1;j<n;j++){
                dp[i][j]=dp[i-1][j]+dp[i][j-1];
            }
        }
        for(int[] arr:dp){
            System.out.println(Arrays.toString(arr));
        }
        return dp[m-1][n-1];
    }

    @Test
    public void test(){
        int i = uniquePaths(3, 2);
        System.out.println(i);
    }
}
